<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:composite="http://java.sun.com/jsf/composite">

<composite:interface>
	<composite:attribute name="id" reqired="true" />
	<composite:attribute name="label" reqired="true" />
	<composite:attribute name="maxlength" default="100" />
	<composite:attribute name="size" default="30" />
	<composite:attribute name="rows" default="3" />
	<composite:attribute name="cols" default="40" />
	<composite:attribute name="inputType" default="inputText" />
	<composite:attribute name="entity" />
</composite:interface>

<composite:implementation>

	<h:outputLabel id="${cc.attrs.id}LabelT" value="${cc.attrs.label}"
		for="#{cc.attrs.id}T" rendered="#{cc.attrs.inputType eq 'inputText'}" />
	<h:inputText id="#{cc.attrs.id}T" value="#{cc.attrs.entity}"
		size="#{cc.attrs.size}" maxlength="#{cc.attrs.maxlength}"
		rendered="#{cc.attrs.inputType eq 'inputText'}">
		<composite:insertChildren />
	</h:inputText>

<c:if test="${empty label}">
		<c:set var="label" value="${fieldName}Label" />
	</c:if>
	<c:if test="${empty rendered}">
		<c:set var="rendered" value="true" />
	</c:if>
	<c:if test="${empty type}">
		<c:set var="type" value="outputText" />
	</c:if>
	<c:if test="${empty id}">
		<c:set var="id" value="#{fieldName}id" />
	</c:if>
	<c:choose>
		<c:when test='${rendered == "true"}'>
			<c:choose>
				<c:when test='${type == "outputText"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}" value="#{entity[fieldName]}" />
				</c:when>
				<c:when test='${type == "outputDate"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}" value="${entity[fieldName]}">
						<f:convertDateTime locale="IT" type="date" dateStyle="medium" />
					</h:outputText>
				</c:when>
				<c:when test='${type == "outputDateTime"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}" value="${entity[fieldName]}">
						<f:convertDateTime type="both" pattern="dd/M/yy HH:mm" />
					</h:outputText>
				</c:when>
				<c:when test='${type == "link"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputLink id="${id}" value="${val}">
						<h:outputText value="${label}" />
					</h:outputLink>
				</c:when>
				<c:when test='${type == "getCodice"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}" value="#{fn:getCodice(entity[fieldName])}" />
				</c:when>
				<c:when test='${type == "getArrayValue"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}" value="#{fn:getArrayValue(campo,entity)}" />
				</c:when>
				<c:when test='${type == "getEntityTypeVisual"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}"
						value="#{fn:getEntityTypeVisual(fieldName)}" />
				</c:when>
				<c:when test='${type == "getContactType"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}" value="#{fn:getContactType(fieldName)}" />
				</c:when>
				<c:when test='${type == "htmlText"}'>
					<div id="#{id}">
						<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
						<h:outputText value="#{fn:nl2br(entity[fieldName])}"
							escape="false" />
					</div>
				</c:when>
				<c:when test='${type == "boolean"}'>
					<h:outputLabel id="#{id}Label" value="${label}" for="${id}" />
					<h:outputText id="${id}si" value="SI"
						rendered="#{entity[fieldName] == true}" />
					<h:outputText id="${id}no" value="NO"
						rendered="#{entity[fieldName] == false}" />

				</c:when>
			</c:choose>
		</c:when>
	</c:choose>



</composite:implementation>
</html>